<?php

class producttypeAction extends Action
{


    public function producttypeaddsave()
    {
        $producttype = new producttypeModel();
        if (!$producttype->create())
        {
            $this->error($producttype->getError());
        } else
        {
            $id=$producttype->add();
            $this->assign("jumpUrl", U("producttype/index"));
            $this->success("添加成功");
        }
    }

    public function index()
    {
        $producttype = new producttypeModel();
        import("ORG.Util.Page");
        $totalnum = $producttype->count();
        $list = $producttype->page($_GET['p'])->limit(10)->select();
        $this->assign("list", $list);
        $page = new Page($totalnum, 10);
        $page->rollPage = 10;
        $page->setConfig("prev", "上一页");
        $page->setConfig("next", "下一页");
        $page->setConfig("first", "首页");
        $page->setConfig("last", "末页");
        $page->setConfig("theme", "共%totalRow%%header%条数据 %nowPage%/%totalPage%页  %first% %upPage%   %linkPage%  %downPage% %end%");
        $pageshow = $page->show();
        $this->assign("pageshow", $pageshow);
        $this->display();
    }

    public function del()
    {
        $id = I('get.id');
        $producttype = new producttypeModel();
        $result = $producttype->where('id=' . $id)->delete();

        if (!$result)
        {
            $this->error("删除失败");
        } else
        {
            $this->success("删除成功");
        }
    }

    public function _empty(){
   //空操作
    $this->error("您访问的页面不存在！");
    }

}
?>